package com.xian.ai.code.core.parser;

import com.xian.ai.code.core.parser.parserImple.HtmlCodeParser;
import com.xian.ai.code.core.parser.parserImple.MultiFileCodeParser;
import com.xian.ai.code.exception.BusinessException;
import com.xian.ai.code.exception.ErrorCode;
import com.xian.ai.code.model.enums.CodeGenTypeEnum;

/**
 * @ClassName CodeParserExecutor
 * @Description TODO
 * @Author Zhangxn
 * @Version 1.0
 */
public class CodeParserExecutor {
    private static final HtmlCodeParser htmlCodeParser=new HtmlCodeParser();
    private static final MultiFileCodeParser multiFileCodeParser=new MultiFileCodeParser();
    /****
    * @description: 
    * @param codeContent
	* @param genTypeEnum
    * @return 目前有两种：MultiFileCodeResult和HtmlCodeResult
    * @author Zhangxn
    * @date 2025/8/3
    */
    public static Object executorParser(String codeContent, CodeGenTypeEnum genTypeEnum){
        return switch (genTypeEnum){
            case HTML->htmlCodeParser.parseCode(codeContent);
            case MULTI_FILE->multiFileCodeParser.parseCode(codeContent);
            default-> throw new BusinessException(ErrorCode.PARAMS_ERROR,"不支持这种类型的代码生成");
        };
    }
}
